﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
using System.IO;
using System.Drawing;
public partial class administrator_uc_admin_a_modules : WebPageSecurity
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindListBoxSysTable();
    }
    private void BindListBoxSysTable()
    {
        ListBoxMoudle.DataSource = new BLL.CmsBLL().SysTabel_GetListName();
        ListBoxMoudle.DataValueField = "name";
        ListBoxMoudle.DataTextField = "name";
        ListBoxMoudle.DataBind();
    }
    protected void lbtAddNewItem_Click(object sender, EventArgs e)
    {
        try
        {
            if (int.Parse("0" + new CmsBLL().Modules_CheckPermissFuncID(txtModuleID.Text.Trim())) > 0)
            {
                lblMessage.Text = "<b>" + txtModuleID.Text + "</b> đã tồn tại!";
                return;
            }
            new CmsBLL().Modules_InsertItem(txtModuleID.Text, txtModuleName.Text, int.Parse("0" + txtSortIndex.Text));
            lblMessage.Text = "Thêm mới thành công!";         
            ResetForm();
        }
        catch (Exception ex)
        {
            lblMessage.Text = "ERROR! " + ex.Message.ToString();
        }
    }
    private void ResetForm()
    {
        txtModuleID.Text = "";
        txtModuleName.Text = "";
        txtSortIndex.Text = "";
        txtModuleID.Focus();
    }
}